<template>
  <div class="app-container" style="padding-top: 0px;">
    
    <el-row style="margin-top: 10px;" :gutter="10" v-if="optType != 'view'" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="routeprocessList">
      <el-table-column label="工序编码" width="120px" fixed align="center" prop="processCode" />
      <el-table-column label="工序名称" width="150px" fixed align="center" prop="processName" />
      <el-table-column label="下一道工序" width="150px" align="center" prop="nextProcessName" />
      <el-table-column label="与下一道工序关系" width="150px" align="center" prop="linkType">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.mes_link_type" :value="scope.row.linkType" />
        </template>
      </el-table-column>
      <el-table-column label="关键工序" width="100px" align="center" prop="keyFlag">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.keyFlag" />
        </template>
      </el-table-column>
      <!-- <el-table-column label="准备时间" align="center" prop="defaultPreTime" />
      <el-table-column label="等待时间" align="center" prop="defaultSufTime" /> -->
      <el-table-column label="标准工时" align="center" prop="manHour" />
      <el-table-column label="SOP" align="center" prop="fileList">
        <template slot-scope="scope">
          <el-image
            style="width: 100px; height: 100px"
            :src="scope.row.imageUrl"
      ></el-image>
        </template>
      </el-table-column>
      
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

  
  </div>
</template>

<script>
import { listRouteprocess} from "@/api/mes/pro/routeSopProcess";
export default {
  name: "RouteprocessSop",
  dicts: ['mes_link_type', 'sys_yes_no'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 工艺组成表格数据
      routeprocessList: [],
      //工序选项
      processOptions: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 文件类型
      fileType: ["doc", "docx", "xlsx", "xls", "ppt", "txt", "pdf",'png', 'jpg', 'jpeg'],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        routeId: this.routeId,
        processId: null,
        processCode: null,
        processName: null,
        orderNum: null,
        nextProcessId: null,
        nextProcessCode: null,
        nextProcessName: null,
        linkType: null,
        defaultPreTime: null,
        defaultSufTime: null,
        colorCode: null,
      },
      // 表单参数
      form: {},
      // 表单校验
    
    };
  },
  props: {
    routeId: undefined,
    optType: undefined
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询工艺组成列表 */
    getList() {
      this.loading = true;
      listRouteprocess(this.queryParams).then(response => {
        this.routeprocessList = response.rows;
        this.routeprocessList.map(item=>{
            item.imageUrl=this.fileRender(item);
        });
        this.total = response.total;
        this.loading = false;
      });
    },
    fileRender(routeprocessItem) {
      let list = routeprocessItem.fileList;
      let url = ""
      if(list!=undefined&&list.length>0){
        return list[0].url;
      }
      return url
    },
   
   
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
   
   
    /** 删除按钮操作 */
    handleDelete(row) {
      const recordIds = row.recordId || this.ids;
      this.$modal.confirm('是否确认删除工艺组成编号为"' + recordIds + '"的数据项？').then(function () {
        return delRouteprocess(recordIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('mes/pro/routeprocess/export', {
        ...this.queryParams
      }, `routeprocess_${new Date().getTime()}.xlsx`)
    },
  
    
  }
};
</script>
